**************************************************************************************************************************************************
****************************** Wealth-Income Ratios in Free Market Capitalism: Switzerland, 1900-2020 ********************************************
**************************************************************************************************************************************************
clear all
set more off
set scheme s1color  

**Author: Enea Baselgia and Isabel Z. Martinez
**Date: January, 25 2023

*** set this path to the current directory
*** global mypath "C:\Users\EBaselgia\Dropbox\WIR_project\Publication_process\replication"

***read data 
cd "$mypath/final_data/"
use "WIR_final.dta", clear

mkdir "$mypath/output"
mkdir "$mypath/output/figures"
mkdir "$mypath/output/tables"
cd "$mypath/output/figures/"


***********************************************************************************************
******************* RESTAT Figures - GRAYSCALE ************************************************

// generate a private WIR series for which we have actual observation from tax data (i.e. delete the interpolated datapoints)
gen ch_pWIR_mis = ch_pWIR
replace ch_pWIR_mis = . if year > 1900 & year < 1910 | year == 1911 | year == 1912 | year == 1914 | year > 1915 & year < 1919 | year == 1920 | year > 1921 & year < 1925
replace ch_pWIR_mis = . if year > 1925 & year < 1929 | year > 1929 & year < 1934 | year == 1935 | year == 1937 | year == 1939 | year > 1941 & year < 1945
replace ch_pWIR_mis = . if year == 1946 | year == 1948| year == 1950|year == 1952| year == 1954 | year == 1956 | year > 1957 & year < 1969 | year > 1969 & year < 1981

*** Label variables
label variable ch_pWIR "Switzerland" 
label variable ch_pWIR_mis "Switzerland" 
label variable DE_pWIR "Germany"
label variable ES_pWIR "Spain"
label variable FR_pWIR "France"
label variable GB_pWIR "United Kingdom"
label variable IT_pWIR "Italy"
label variable SE_pWIR "Sweden"
label variable US_pWIR "United States"


tw (connect ch_pWIR_mis year if year>=1900, lcolor(gs1) msymb(O) msize(1.2) mcolor(gs1) lpattern() lwidth(medthick)) ///
(line DE_pWIR year if year>=1900, lcolor(gs4) lpattern(dash) lwidth(medthick)  ) ///
(line FR_pWIR year if year>=1900, lcolor(gs7) lpattern(.-) lwidth(medthick)  ) ///
(line GB_pWIR year if year>=1900, lcolor(gs10) lpattern() lwidth(medthick)  ) ///
, title() legend(order(1 2 3 4)) ytitle(Value of wealth (in % of national income)) xtitle("") ///
ylab(2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%" 8 "800%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)

graph export "Fig_1a.pdf", replace



tw (connect ch_pWIR_mis year if year>=1900, lcolor(gs1) msymb(O) msize(1.2) mcolor(gs1) lpattern() lwidth(medthick)) ///
(line ES_pWIR year if year>=1900, lcolor(gs4) lpattern(dash) lwidth(medthick)  ) ///
(line SE_pWIR year if year>=1900, lcolor(gs7) lpattern(.-) lwidth(medthick)  ) ///
(line US_pWIR year if year>=1900, lcolor(gs10) lpattern() lwidth(medthick)  ) ///
, title() legend(order(1 2 3 4)) ytitle(Value of wealth (in % of national income)) xtitle("") ///
ylab(2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%" 8 "800%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)

graph export "Fig_1b.pdf", replace



*** Re-label variables (original label)
label variable ch_pWIR "Net Private Wealth-Income Ratio" 
label variable DE_pWIR_excl_domW_agriW "Net Private WIR exclusive Other domestic pW & agri_land - Germany"
label variable FR_pWIR_excl_domW_agriW "Net Private WIR exclusive Other domestic pW & agri_land - France"
label variable IT_pWIR_excl_domW_agriW "Net Private WIR exclusive Other domestic pW & agri_land - Italy"
label variable SE_pWIR_excl_domW_agriW "Net Private WIR exclusive Other domestic pW & agri_land - Sweden"
label variable US_pWIR_excl_domW_agriW "Net Private WIR exclusive Other domestic pW & agri_land - United States"
label variable ch_pWIR "Private Wealth-Income Ratio" 
label variable DE_pWIR "Private Wealth-Income Ratio - Germany"
label variable FR_pWIR "Private Wealth-Income Ratio - France"
label variable GB_pWIR "Private Wealth-Income Ratio - United Kingdom"
label variable IT_pWIR "Private Wealth-Income Ratio - Italy"
label variable ES_pWIR "Private Wealth-Income Ratio - Spain"
label variable SE_pWIR "Private Wealth-Income Ratio - Sweden"
label variable US_pWIR "Private Wealth-Income Ratio - United States"


***********************************************************************************************************************************************************
*** Label variables
label variable ch_nWIR_T "Switzerland"
label variable DE_nWIR_excl_domW_agriW "Germany"
label variable FR_nWIR_excl_domW_agriW "France"
label variable GB_nWIR_excl_domW_agriW "United Kingdom"
label variable IT_nWIR_excl_domW_agriW "Italy"
label variable SE_nWIR_excl_domW_agriW "Sweden"
label variable US_nWIR_excl_domW_agriW "United States"


*** National WIR Switzerland, Germany, France, Italy, Sweden, United States ***
tw (connect ch_nWIR_T year if year>=1990, lcolor(gs1) mcolor(gs1) lwidth(medthick) ) ///
	(connect DE_nWIR_excl_domW_agriW year if year>=1990, lcolor(gs3) mcolor(gs3) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_nWIR_excl_domW_agriW year if year>=1990, lcolor(gs5) mcolor(gs5) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_nWIR_excl_domW_agriW year if year>=1990, lcolor(gs7) mcolor(gs7) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_nWIR_excl_domW_agriW year if year>=1990, lcolor(gs9) mcolor(gs9) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_nWIR_excl_domW_agriW year if year>=1990, lcolor(gs11) mcolor(gs11) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(1 "100%" 3 "300%" 5 "500%" 7 "700%" 9 "900%", grid) ymtick(1(1)9, grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020, grid)

	graph export "Fig_2.pdf", replace

  
  




***********************************************************************************************************************************************************	
mylabels 400(100)800, myscale(@/100) suffix("%") local(myla1) // if in format 0.32
mylabels 0(10)70, myscale(@/100) suffix("%") local(myla2) // if in format 0.32
tw (connect ch_pWIR year if year>=1990, lcolor(gs1) mcolor(gs1) lwidth(medthick) ) ///
	(connect ch_gWIR_net_staat_cor year if year>=1990, yaxis(2)lcolor(gs8) mcolor(gs8) msymb(T) lpattern() lwidth(medthick) ) ///
	, ytitle("Value of wealth (in % of national income)") ytitle("", axis(2)) xtitle("") ///
	ylab(`myla1', grid labcolor(gs1)) ylab(`myla2', axis(2) labcolor(gs8)) xlab(1990(10)2020,grid) xmtick(1990(5)2020, grid) ///
	legend(order(1 "Private wealth (left scale)" 2 "Public wealth (right scale)") )
	
	graph export "Fig_3a.pdf", replace

	
	
***********************************************************************************************************************************************************
	 	 
*** growth rate of non-financial wealth at the federal level corrected and original series	 
gen ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_gr_bund if year != 2007 & year != 2008
replace ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_grmean2[119] if missing(ch_gW_nonfin_gr_bund_cor)
replace ch_gW_nonfin_gr_bund_cor =. if year<=1990
replace ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_gr_bund_cor - 1
gen ch_gW_nonfin_gr_bund_1 = ch_gW_nonfin_gr_bund - 1 
drop ch_gW_nonfin_gr_bund_cor
		   

*** Main Components of Public Wealthby government level as Share of total wealth
gen ch_gW_share = ch_gWIR_net_staat_cor/ch_nWIR_T
gen ch_gW_share_bund = ch_gWIR_net_bund_cor/ch_nWIR_T
gen ch_gW_share_gdn = ch_gWIR_net_gdn/ch_nWIR_T
gen ch_gW_share_ktn = ch_gWIR_net_ktn/ch_nWIR_T
gen ch_gW_share_sv = ch_gWIR_net_sv/ch_nWIR_T

gen ch_govW_share_sv2 = ch_gW_share_sv + ch_gW_share_gdn + ch_gW_share_bund + ch_gW_share_ktn 
gen ch_govW_share_bu2 = ch_gW_share_bund + ch_gW_share_ktn + ch_gW_share_gdn
gen ch_govW_share_gdn2 = ch_gW_share_gdn + ch_gW_share_ktn 

label var ch_govW_share_sv2 "Social security funds"
label var ch_govW_share_gdn2 "Municipalities"
label var ch_govW_share_bu2 "Confederation"
label var ch_gW_share_ktn "Cantons"


*** Main components of public wealth at each governmet lelvel
***label variables
label variable ch_gWIR_nonfin_gdn "Non-financial assets"
label variable ch_gWIR_fin_gdn "Financial assets"
label variable ch_gWIR_liab_gdn "Liabilities"
label variable ch_gWIR_nonfin_ktn "Non-financial assets"
label variable ch_gWIR_fin_ktn "Financial assets"
label variable ch_gWIR_liab_ktn "Liabilities"
label variable ch_gWIR_nonfin_bund_cor "Non-financial assets"
label variable ch_gWIR_fin_bund "Financial assets"
label variable ch_gWIR_liab_bund "Liabilities"
label variable ch_gWIR_nonfin_sv "Non-financial assets"
label variable ch_gWIR_fin_sv "Financial assets"
label variable ch_gWIR_liab_sv "Liabilities"           
label variable ch_gWIR_nonfin_staat_cor "Non-financial assets"
label variable ch_gWIR_fin_staat "Financial assets"
label variable ch_gWIR_liab_staat "Liabilities"
            

tw (connect ch_gWIR_nonfin_staat_cor year if year>=1990, lcolor(gs1) mcolor(gs1) lwidth(medthick) ) ///
	(connect ch_gWIR_fin_staat year if year>=1990, lcolor(gs6) mcolor(gs6) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_liab_staat year if year>=1990, lcolor(gs11) mcolor(gs11) msize(1.3) msymb(D) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(0.2 "20%" 0.3 "30%" 0.4 "40%" 0.5 "50%" 0.6 "60%" 0.7 "70%" 0.8 "80%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020, grid)
	
	graph export "Fig_3b.pdf", replace


	
***********************************************************************************************************************************************************



mylabels 0(1)9, myscale(@/100) suffix("%") local(myla) // if in format 0.32
tw (area ch_govW_share_sv2 year if year >=1990 , color(gs13) lcolor(black) lwidth(vthin)) ///
	(area ch_govW_share_bu2 year if year >=1990, color(gs9) lcolor(black) lwidth(vthin)) ///
    (area ch_govW_share_gdn2 year if year >=1990, color(gs5) lcolor(black) lwidth(vthin)) ///
	(area ch_gW_share_ktn year if year >=1990 , color(gs1) lcolor(black) lwidth(vthin)) ///
	, xlab (1990(10)2020) xmtick(1990(5)2020, grid) ylab(`myla', grid) ytitle("in % of national wealth") xtitle("")

	graph export "Fig_4.pdf", replace

	

***********************************************************************************************************************************************************
	
	
** Main components Private Wealth 
label variable ch_pWIR_netfin "Net-financial wealth"
label variable ch_pWIR_pension "Pension wealth"
label variable ch_pWIR_housing "Gross-housing wealth"

tw (connect ch_pWIR_netfin year if year>=2000, lcolor(gs1) mcolor(gs1) msymb(T) lwidth(medthick) ) ///
	(connect ch_pWIR_pension year if year>=2000, lcolor(gs6) mcolor(gs6) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	(connect ch_pWIR_housing year if year>=2000, lcolor(gs11) mcolor(gs11) msymb(O) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(0 "" 1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%", grid) xlab(2000(5)2020,grid)

graph export "Fig_5a.pdf", replace


***********************************************************************************************************************************************************

*** Private Wealth -- Household debt*******
gen ch_pWIR_mortgages = ch_pW_mortgages_T/ch_nni_T 

 
tw (connect ch_pWIR_mortgages year if year>=2000, lcolor(gs8) mcolor(gs8) lwidth(medthick) ) ///
	(connect ch_pWIR_liabil year if year>=2000, lcolor(gs1) mcolor(gs1) msymb(T) lpattern() lwidth(medthick) ) ///
	, title("") legend(label(1 "Mortgages") label(2 "Total Liabilities") size(small)) ytitle("in % of national income") xtitle("") ///
	ylab(1.0 "100%" 1.2 "120%" 1.4 "140%" 1.6 "160%" 1.8 "180%", grid) xlab(2000(5)2020,grid)

	graph export "Fig_5b.pdf", replace


***********************************************************************************************************************************************************
cd "$mypath/"
